/*
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#include "callbacks.h"
#include "theme.h"
#include "widget.h"

#include <glib.h>
#include <glib/gprintf.h>
#include <gtk/gtk.h>
#include <clutter/clutter.h>
#include <clutter-gtk/gtk-clutter-embed.h>
#include <stdio.h>

ClutterActor *stage = NULL;

int main(int argc, char *argv[])
{
    ClutterColor stageColor;
    GtkWidget *window;
    GtkWidget *vbox;
    GtkWidget *swin;
    GtkWidget *clutter;

    gtk_clutter_init (&argc, &argv);

    // Window
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title (GTK_WINDOW (window), "Seastar");

    seastar_theme_set_colors (window);

    g_signal_connect (GTK_WINDOW (window), "destroy",
                        G_CALLBACK (on_window_destroy), NULL);

    // Vbox
    vbox = gtk_vbox_new (FALSE, 6);
    gtk_container_add (GTK_CONTAINER (window), vbox);
    gtk_widget_show (vbox);

    // ScrolledWindow
    swin = gtk_scrolled_window_new (NULL, NULL);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin),
                                    GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (swin),
                                            GTK_SHADOW_IN);
    gtk_box_pack_start (GTK_BOX (vbox), swin, TRUE, TRUE, 0);
    gtk_widget_show (swin);

    clutter = gtk_clutter_embed_new ();
    gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (swin), clutter);
    gtk_widget_show (clutter);

    gtk_widget_set_size_request (clutter, 600, 400);

    stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (clutter));
    clutter_actor_show (stage);
    stageColor = seastar_theme_get_color (SEASTAR_THEME_BASE);
    clutter_stage_set_color (CLUTTER_STAGE (stage), &stageColor);

    gtk_widget_show (window);

    /* Fun begins *************************************************************/

    ClutterActor *label;
    const gchar *font = "Sans 8";
    const gchar *text = "All work and no play makes Tux a dull penguin!";
    ClutterColor txtcol = seastar_theme_get_color (SEASTAR_THEME_TEXT);

    label = clutter_label_new_full (font, text, &txtcol);
    clutter_actor_set_position (CLUTTER_ACTOR (label), 10, 10);
    clutter_actor_set_size (CLUTTER_ACTOR (label), 350, 100);
    clutter_container_add_actor (CLUTTER_CONTAINER (stage), label);
    clutter_actor_show (label);

    /* Fun ends ***************************************************************/

    gtk_main ();

    return 0;
}

